package com.ruoyi.yljf.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.yljf.mapper.EbookMapper;
import com.ruoyi.yljf.domain.Ebook;
import com.ruoyi.yljf.service.IEbookService;

import javax.annotation.Resource;

/**
 * 电子书Service业务层处理
 * 
 * @author metaee
 * @date 2025-04-28
 */
@Service
public class EbookServiceImpl extends ServiceImpl<EbookMapper, Ebook> implements IEbookService {
    @Resource
    private EbookMapper ebookMapper;
    
    /**
     * 查询电子书列表
     * 
     * @param ebook 电子书
     * @return 电子书
     */
    @Override
    public List<Ebook> selectEbookList(Ebook ebook) {
    	LambdaQueryWrapper<Ebook> queryWrapper = Wrappers.lambdaQuery();
        if (StringUtils.isNotEmpty(ebook.getName())) {
			queryWrapper.like(Ebook::getName, ebook.getName());
		}
        if (StringUtils.isNotEmpty(ebook.getAuthor())) {
			queryWrapper.eq(Ebook::getAuthor, ebook.getAuthor());
		}
        if (StringUtils.isNotEmpty(ebook.getImg())) {
			queryWrapper.eq(Ebook::getImg, ebook.getImg());
		}
        if (StringUtils.isNotNull(ebook.getCategoryId())) {
			queryWrapper.eq(Ebook::getCategoryId, ebook.getCategoryId());
		}
        if (StringUtils.isNotNull(ebook.getIsfree())) {
			queryWrapper.eq(Ebook::getIsfree, ebook.getIsfree());
		}
        if (StringUtils.isNotEmpty(ebook.getSynopsis())) {
			queryWrapper.eq(Ebook::getSynopsis, ebook.getSynopsis());
		}
        if (StringUtils.isNotNull(ebook.getPageViews())) {
			queryWrapper.eq(Ebook::getPageViews, ebook.getPageViews());
		}
        if (StringUtils.isNotNull(ebook.getBookPrice())) {
			queryWrapper.eq(Ebook::getBookPrice, ebook.getBookPrice());
		}
        if (StringUtils.isNotNull(ebook.getWordCount())) {
			queryWrapper.eq(Ebook::getWordCount, ebook.getWordCount());
		}
        if (StringUtils.isNotEmpty(ebook.getFileUri())) {
			queryWrapper.eq(Ebook::getFileUri, ebook.getFileUri());
		}
        return ebookMapper.selectList(queryWrapper);
    }
}
